<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/views/include/nocachehead.jsp"%>
<title>编辑图片信息</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/validator/editPhotoForm.js"></script>
</head>
<body>
	<div>
		<!-- main content start -->
		<div>
			<c:out value="${requestScope.errMsg}" escapeXml="false"/>
			<form id="editPhotoForm" name="editPhotoForm" action="${pageContext.request.contextPath}/album/editphoto/${requestScope.photo.id }.html" method="post" >
				<div id="editPhoto">
					<div class="">
						<p>
							<label>描述:</label>
							<textarea id="description" name="description" rows="" cols=""><c:out value="${requestScope.photo.description}" /></textarea>
						</p>
					</div>
					<div>
						<div><img src="${pageContext.request.contextPath}/image/${requestScope.photo.smallFile}.${requestScope.photo.ext}"/></div>
						<p><input type="checkbox" id="setCover" name="setCover"/><label>设置为相册封面</label></p>
						<p>转移到:<select name="toAlbumId" id="toAlbumId">
							<c:forEach items="${requestScope.albums}" var="album" >
								 <option value="${album.id }" <c:if test="${album.id eq requestScope.photo.albumId}"> selected="selected" </c:if> ><c:out value="${album.albumName}"/></option>
							</c:forEach>
						</select></p>
					</div>
					<input type="hidden" name="submitToken" value="<skyline:sessionAttribute key="SESSION_SUBMIT_TOKEN" />"/>
				</div>
				<div class="">
					<button type="submit" class="" >修改</button>
					<button type="button" class="" onclick="window.location='${pageContext.request.contextPath}/album/photo/${requestScope.photo.id}.html';">取消</button>
				</div>
			</form>
				<script type="text/javascript">
					(function($){$(document).ready(function(){
						$('#editPhotoForm').submit(function(){
							return true;
						});
						$('#toAlbumId').change(function(){
							if($('#toAlbumId option:selected').val() != ${requestScope.photo.albumId}) {
								$('#setCover').removeAttr("checked");
								$('#setCover').attr("disabled","disabled");
							} else {
								$('#setCover').removeAttr("disabled");
							}
						});
						$('#setCover').click(function(){
							if($('#setCover').attr("checked")) {
								$('#toAlbumId').val('${requestScope.photo.albumId}');
								$('#toAlbumId').attr("disabled","disabled");
							} else {
								$('#toAlbumId').removeAttr("disabled");
							}
						});
						if('${requestScope.photo.smallFile}' == '${requestScope.cover}') {
							$('#setCover').attr("checked","checked");
							$('#toAlbumId').val('${requestScope.photo.albumId}');
							$('#toAlbumId').attr("disabled","disabled");
						}
					});})(jQuery);
				</script>
		</div>
		<!-- main content end -->
	</div>
</body>
</html>